@extends('layouts.master')

@section('title')
    产品录入——木投网商城管理后台
@stop

@section('app_css')
    <link rel="stylesheet" href="/resource/css/bootstrap.min.css">
    <link rel="stylesheet" href="/resource/css/font-awesome.min.css">
    <link rel="stylesheet" href="/resource/css/animate.min.css">
    <link rel="stylesheet" href="/resource/css/custom.css">
    <link rel="stylesheet" href="/resource/css/green.css">
    <link rel="stylesheet" href="/resource/css/fileinput.min.css">
    @stop

@section('app_js')
    <!--[if lt IE 9]>
    <script type="text/javascript" src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script type="text/javascript" src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript" src="/resource/js/jquery.min.js"></script>
    <script type="text/javascript" src="/resource/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/resource/js/custom.js"></script>
    <!-- icheck -->
    <script type="text/javascript" src="/resource/js/icheck.min.js"></script>
    <!-- Datatables -->
    <script type="text/javascript" src="/resource/js/jquery.dataTables.js"></script>
    <script type="text/javascript" src="/resource/js/J_main.js"></script>
    <!-- 添加图片 -->
    <script type="text/javascript" src="/resource/js/fileinput.min.js"></script>
    <script type="text/javascript" src="/resource/js/fileinput_locale_zh.js"></script>
    <script type="text/javascript" src="/resource/js/T.js"></script>
   <script type="text/javascript">
        $(document).delegate('#quality','change',function(){
            var quality = $('#quality').val();
            if(quality > 0){
                var data = {quality:quality};
                T.restGet('/admin/level_info',data,function(response){
                    if(response.data.length > 0){
                        $.each(response.data, function(i,n){
                            $('#level').append("<option value='"+ n.level_id +"'>"+n.level_name+"</option>");
                        });
                    }
                });
                T.restGet('/spec_info',data,function(response){
                    $.each(response.data, function(i,n){
                        $('#spec').append("<option value='"+ n.spec_id +"'>"+n.spec_name+"</option>");
                    });
                });
            }
        });
       //分类联动
        $('[name="category"]').bind('change',function(){
            var str = "<option value=\"0\">请选择</option>";
            var category = $('[name="category"]').val();
            $.ajax({
                url : '/admin/linkage',
                type : "POST",
                data : {id:category},
                dataType : "json",
                cache:"false",
                timeout:30000,
                success : function(json) {
                    $.each(json,function(ind,arr){
                        str += "<option value="+arr.cate_id+">";
                        str += arr.cate_name;
                        str += "</option>";
                        $('[name="classes"]').html(str);
                    });
                }
            });
        });
        $('[name="classes"]').bind('change',function(){
            var str = "<option value=\"0\">请选择</option>";
            var category = $('[name="classes"]').val();
            $.ajax({
                url : '/admin/linkage',
                type : "POST",
                data : {id:category},
                dataType : "json",
                cache:"false",
                timeout:30000,
                success : function(json) {
                    $.each(json,function(ind,arr){
                        str += "<option value="+arr.cate_id+">";
                        str += arr.cate_name;
                        str += "</option>";
                        $('[name="quality"]').html(str);
                    });
                }
            });
        });
    </script>
@stop

@section('content')
    <body class="nav-md">

    <div class="container body">


        <div class="main_container">

            @include('common.admin_menu')

                    <!-- top navigation -->
            @include('common.admin_nav')
                    <!-- /top navigation -->


            <!-- page content -->
            <div class="right_col" role="main">

                <div class="">

                    <div class="row cont">

                        <div class="col-md-6 col-sm-12 col-xs-12">
                            <div class="x_panel">
                                <div class="x_title">
                                    <h2>产品录入<small>产品管理</small></h2>
                                    <div class="clearfix"></div>
                                </div>

                                <div class="x_content">
                                    <br />

                                    @if(empty($product))
                                        {{ Form::open(['url'=>'/admin/product_import_action', 'id'=>'demo-form2', 'class'=> 'form-horizontal form-label-left', 'files' => true, 'method' => 'post']) }}
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">所属商家</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="supplier_id" class="form-control col-md-7 col-xs-12">
                                                    <option value="0">请选择</option>
                                                    @foreach($supplier as $v)
                                                        <option value="{{$v->supplier_id}}">{{$v->supplier_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="control-label col-md-2 col-sm-2 col-xs-12" for="first-name">产品名称
                                            </label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="product_name" type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">分类</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="category" class="form-control col-md-7 col-xs-12">
                                                    <option value="0">请选择</option>
                                                    @foreach($cate as $v)
                                                        <option value="{{$v->cate_id}}">{{$v->cate_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12"></label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="classes" class="form-control col-md-7 col-xs-12">
                                                    <option value="0">请选择</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12"></label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="quality" class="form-control col-md-7 col-xs-12">
                                                    <option value="0">请选择</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">单位</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="unit" class="form-control col-md-7 col-xs-12" type="text">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">库存</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="stock" class="form-control col-md-7 col-xs-12" type="text">
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">价格</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="price" class="form-control col-md-7 col-xs-12" type="text" >
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">等级</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="level" class="form-control col-md-7 col-xs-12" type="text" >
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">商品描述</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <textarea name="description" class="form-control col-md-7 col-xs-12"></textarea>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">产地</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="place" class="form-control col-md-7 col-xs-12" type="text" >
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">规格</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="spec" class="form-control col-md-7 col-xs-12" type="text" >
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">仓储地</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input class="form-control col-md-7 col-xs-12" type="text" name="storage">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">仓储地电话</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input class="form-control col-md-7 col-xs-12" type="text" name="phone">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">起订量</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input class="form-control col-md-7 col-xs-12" type="text" name="start_num">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">详情图一</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="product_img" type="file" class="file form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">详情图二</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="show_pic1" type="file" class="file form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">详情图三</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="show_pic2" type="file" class="file form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="ln_solid"></div>
                                        <div class="form-group">
                                            <div class="col-md-10 col-sm-10 col-xs-12 col-md-offset-3">
                                                <button type="reset" class="btn btn-primary">取消</button>
                                                <button type="submit" class="btn btn-success">提交</button>
                                            </div>
                                        </div>

                                        {{ Form::close() }}
                                    @else
                                        {{ Form::open(['url'=>'/admin/product_update_action', 'id'=>'demo-form2', 'class'=> 'form-horizontal form-label-left', 'files' => true, 'method' => 'post']) }}
                                        <input type="hidden" value="{{$product->product_id}}" name="product_id">
                                        <input type="hidden" value="{{$product->show_img1}}" name="product_img1_old">
                                        <input type="hidden" value="{{$product->show_img2}}" name="product_img2_old">
                                        <input type="hidden" value="{{$product->show_img3}}" name="product_img3_old">
                                        <div class="form-group">
                                            <label class="control-label col-md-2 col-sm-2 col-xs-12" for="first-name">产品名称
                                            </label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="product_name" type="text" id="first-name" required="required" class="form-control col-md-7 col-xs-12" value="{{$product->product_name}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">分类</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="category" class="form-control col-md-7 col-xs-12">
                                                    <option value="0">请选择</option>
                                                    @foreach($cate as $v)
                                                    <option value="{{$v->cate_id}}" @if($product->category == $v->cate_id)selected @endif>{{$v->cate_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12"></label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="classes" class="form-control col-md-7 col-xs-12">

                                                    @foreach($erji as $v)
                                                        <option value="{{$v->cate_id}}" @if($product->classes == $v->cate_id)selected @endif>{{$v->cate_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12"></label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <select name="quality" class="form-control col-md-7 col-xs-12">

                                                    @foreach($sanji as $v)
                                                        <option value="{{$v->cate_id}}" @if($product->quality == $v->cate_id)selected @endif>{{$v->cate_name}}</option>
                                                    @endforeach
                                                </select>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">库存</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="stock" class="form-control col-md-7 col-xs-12" type="text" value="{{$product->stock}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">材质</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="classes" class="form-control col-md-7 col-xs-12" type="text" value="{{$product->classes}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">单位</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="unit" class="form-control col-md-7 col-xs-12" type="text"  value="{{$product->unit}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">价格</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="price" class="form-control col-md-7 col-xs-12" type="text" value="{{$product->price}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">等级</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="level" class="form-control col-md-7 col-xs-12" type="text" value="{{$product->level}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">商品描述</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                               <textarea class="form-control col-md-7 col-xs-12" name="description">{{$product->description}}</textarea>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">产地</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="place" class="form-control col-md-7 col-xs-12" type="text" value="{{$product->place}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">规格</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input name="spec" class="form-control col-md-7 col-xs-12" type="text" value="{{$product->spec}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">仓储地</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input class="form-control col-md-7 col-xs-12" type="text" name="storage" value="{{$product->storage}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">仓储地电话</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input class="form-control col-md-7 col-xs-12" type="text" name="phone" value="{{$product->phone}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">起订量</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <input class="form-control col-md-7 col-xs-12" type="text" name="start_num" value="{{$product->start_num}}">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">详情图一</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <img src="{{$product->show_img1}}" width="330">
                                                <input name="show_pic1" type="file" class="file form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">详情图二</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <img src="{{$product->show_img2}}" width="330">
                                                <input name="show_pic2" type="file" class="file form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label for="middle-name" class="control-label col-md-2 col-sm-2 col-xs-12">详情图三</label>
                                            <div class="col-md-10 col-sm-10 col-xs-12">
                                                <img src="{{$product->show_img3}}" width="330">
                                                <input name="show_pic3" type="file" class="file form-control col-md-7 col-xs-12">
                                            </div>
                                        </div>
                                        <div class="ln_solid"></div>
                                        <div class="form-group">
                                            <div class="col-md-10 col-sm-10 col-xs-12 col-md-offset-3">
                                                <button type="reset" class="btn btn-primary">取消</button>
                                                <button type="submit" class="btn btn-success">提交</button>
                                            </div>
                                        </div>

                                        {{ Form::close() }}
                                    @endif
                                </div>
                            </div>
                        </div>

                        <br />
                        <br />
                        <br />

                    </div>
                </div>

                <!-- footer content -->

                <footer>
                    <div class="">
                        <p class="pull-right">Copyright 2016 mutouw.com All rights reserved. |
                            <span class="lead"> <i class="fa fa-logo-footer"></i> 木投网后台管理系统</span>
                        </p>
                    </div>
                    <div class="clearfix"></div>
                </footer>
                <!-- /footer content -->
            </div>
            <!-- /page content -->

        </div>
    </div>

    <div id="custom_notifications" class="custom-notifications dsp_none">
        <ul class="list-unstyled notifications clearfix" data-tabbed_notifications="notif-group">
        </ul>
        <div class="clearfix"></div>
        <div id="notif-group" class="tabbed_notifications"></div>
    </div>
    </body>
@stop